#ifndef USERPROG_PAGEDIR_H
#define USERPROG_PAGEDIR_H

#include <stdbool.h>
#include <stdint.h>
#include <kernel/hash.h>
#include "vm/page.h"

#ifdef VM
  struct pgdir_info
  {
     uint32_t* pg_i;
     struct hash pg_h;
  };
  typedef struct pgdir_info* p_info;
#else
  typedef uint32_t* p_info;
#endif

p_info pagedir_create (void);
void pagedir_destroy (p_info pd);
bool pagedir_set_page (p_info pd, void *upage, void *kpage, bool rw);
void *pagedir_get_page (p_info pd, const void *uaddr);
void pagedir_clear_page (p_info pd, void *upage);
bool pagedir_is_dirty (p_info pd, const void *upage);
void pagedir_set_dirty (p_info pd, const void *upage, bool dirty);
bool pagedir_is_accessed (p_info pd, const void *upage);
void pagedir_set_accessed (p_info pd, const void *upage, bool accessed);
void pagedir_activate (p_info pd);
bool pagedir_is_mapped(uint32_t *pd,const void *vaddr);

// 3 idiots added begin
bool pagedir_read_or_write (p_info, void*, bool);
bool pagedir_can_read (p_info, void*);
bool pagedir_can_write (p_info, void*);
struct page_info* pagedir_get_page_new (p_info, void*);
// 3 idiots added end
#endif /* userprog/pagedir.h */
